.class public Lcom/opongo/blogapp/adapter/PostCacheListAdapter;
.super Landroid/widget/ArrayAdapter;
.source "PostCacheListAdapter.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;
    }
.end annotation

.annotation system Ldalvik/annotation/Signature;
    value = {
        "Landroid/widget/ArrayAdapter",
        "<",
        "Lcom/opongo/blogapp/common/Post;",
        ">;"
    }
.end annotation


# static fields
.field public static final DEBUG:Z

.field private static final TAG:Ljava/lang/String;


# instance fields
.field private activity:Landroid/app/Activity;

.field private df:Ljava/text/DateFormat;

.field private imageManager:Lcom/opongo/blogapp/manager/ImageManager;

.field private mInflater:Landroid/view/LayoutInflater;

.field private pTime:Lcom/ocpsoft/pretty/time/PrettyTime;

.field private posts:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList",
            "<",
            "Lcom/opongo/blogapp/common/Post;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .prologue
    .line 39
    sget-boolean v0, Lcom/opongo/blogapp/AbaSettings;->DEBUG:Z

    sput-boolean v0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->DEBUG:Z

    .line 40
    const-class v0, Lcom/opongo/blogapp/adapter/PostListAdapter;

    invoke-virtual {v0}, Ljava/lang/Class;->getSimpleName()Ljava/lang/String;

    move-result-object v0

    sput-object v0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->TAG:Ljava/lang/String;

    .line 36
    return-void
.end method

.method public constructor <init>(Landroid/app/Activity;Landroid/content/Context;ILjava/util/ArrayList;)V
    .locals 3
    .parameter "activity"
    .parameter "context"
    .parameter "textViewResourceId"
    .parameter
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Landroid/app/Activity;",
            "Landroid/content/Context;",
            "I",
            "Ljava/util/ArrayList",
            "<",
            "Lcom/opongo/blogapp/common/Post;",
            ">;)V"
        }
    .end annotation

    .prologue
    .line 54
    .local p4, posts:Ljava/util/ArrayList;,"Ljava/util/ArrayList<Lcom/opongo/blogapp/common/Post;>;"
    invoke-direct {p0, p2, p3, p4}, Landroid/widget/ArrayAdapter;-><init>(Landroid/content/Context;ILjava/util/List;)V

    .line 57
    invoke-static {p2}, Landroid/view/LayoutInflater;->from(Landroid/content/Context;)Landroid/view/LayoutInflater;

    move-result-object v0

    iput-object v0, p0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->mInflater:Landroid/view/LayoutInflater;

    .line 59
    new-instance v0, Ljava/text/SimpleDateFormat;

    const-string v1, "yyyy-MM-dd HH:mm:ss"

    invoke-direct {v0, v1}, Ljava/text/SimpleDateFormat;-><init>(Ljava/lang/String;)V

    iput-object v0, p0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->df:Ljava/text/DateFormat;

    .line 60
    new-instance v0, Lcom/ocpsoft/pretty/time/PrettyTime;

    new-instance v1, Ljava/util/Locale;

    const-string v2, "de"

    invoke-direct {v1, v2}, Ljava/util/Locale;-><init>(Ljava/lang/String;)V

    invoke-direct {v0, v1}, Lcom/ocpsoft/pretty/time/PrettyTime;-><init>(Ljava/util/Locale;)V

    iput-object v0, p0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->pTime:Lcom/ocpsoft/pretty/time/PrettyTime;

    .line 62
    iput-object p1, p0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->activity:Landroid/app/Activity;

    .line 63
    iput-object p4, p0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->posts:Ljava/util/ArrayList;

    .line 65
    new-instance v0, Lcom/opongo/blogapp/manager/ImageManager;

    invoke-direct {v0, p2}, Lcom/opongo/blogapp/manager/ImageManager;-><init>(Landroid/content/Context;)V

    iput-object v0, p0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->imageManager:Lcom/opongo/blogapp/manager/ImageManager;

    .line 66
    return-void
.end method

.method static synthetic access$0()Ljava/lang/String;
    .locals 1

    .prologue
    .line 40
    sget-object v0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->TAG:Ljava/lang/String;

    return-object v0
.end method

.method static synthetic access$1(Lcom/opongo/blogapp/adapter/PostCacheListAdapter;)Landroid/app/Activity;
    .locals 1
    .parameter

    .prologue
    .line 49
    iget-object v0, p0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->activity:Landroid/app/Activity;

    return-object v0
.end method


# virtual methods
.method public getView(ILandroid/view/View;Landroid/view/ViewGroup;)Landroid/view/View;
    .locals 14
    .parameter "position"
    .parameter "convertView"
    .parameter "parent"

    .prologue
    .line 87
    move-object/from16 v7, p2

    .line 89
    .local v7, view:Landroid/view/View;
    if-nez v7, :cond_0

    .line 92
    iget-object v9, p0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->mInflater:Landroid/view/LayoutInflater;

    const v10, 0x7f03000f

    .line 93
    const/4 v11, 0x0

    .line 92
    move-object/from16 v0, p3

    invoke-virtual {v9, v10, v0, v11}, Landroid/view/LayoutInflater;->inflate(ILandroid/view/ViewGroup;Z)Landroid/view/View;

    move-result-object v7

    .line 96
    new-instance v8, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;

    invoke-direct {v8}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;-><init>()V

    .line 101
    .local v8, viewHolder:Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;
    const v9, 0x7f080025

    invoke-virtual {v7, v9}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v9

    check-cast v9, Landroid/widget/ImageView;

    #setter for: Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->mThumbImg:Landroid/widget/ImageView;
    invoke-static {v8, v9}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->access$0(Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;Landroid/widget/ImageView;)V

    .line 102
    const v9, 0x7f080029

    invoke-virtual {v7, v9}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v9

    check-cast v9, Landroid/widget/TextView;

    #setter for: Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->mTitleText:Landroid/widget/TextView;
    invoke-static {v8, v9}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->access$1(Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;Landroid/widget/TextView;)V

    .line 103
    const v9, 0x7f08002b

    invoke-virtual {v7, v9}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v9

    check-cast v9, Landroid/widget/TextView;

    #setter for: Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->mDetailText:Landroid/widget/TextView;
    invoke-static {v8, v9}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->access$2(Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;Landroid/widget/TextView;)V

    .line 104
    const v9, 0x7f08002a

    invoke-virtual {v7, v9}, Landroid/view/View;->findViewById(I)Landroid/view/View;

    move-result-object v9

    check-cast v9, Landroid/widget/Button;

    #setter for: Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->mCommentsCount:Landroid/widget/Button;
    invoke-static {v8, v9}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->access$3(Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;Landroid/widget/Button;)V

    .line 106
    invoke-virtual {v7, v8}, Landroid/view/View;->setTag(Ljava/lang/Object;)V

    .line 109
    .end local v8           #viewHolder:Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;
    :cond_0
    iget-object v9, p0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->posts:Ljava/util/ArrayList;

    invoke-virtual {v9, p1}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v6

    check-cast v6, Lcom/opongo/blogapp/common/Post;

    .line 111
    .local v6, p:Lcom/opongo/blogapp/common/Post;
    if-eqz v6, :cond_2

    .line 114
    const/4 v2, 0x0

    .line 116
    .local v2, date:Ljava/util/Date;
    :try_start_0
    iget-object v9, p0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->df:Ljava/text/DateFormat;

    iget-object v10, v6, Lcom/opongo/blogapp/common/Post;->date:Ljava/lang/String;

    invoke-virtual {v9, v10}, Ljava/text/DateFormat;->parse(Ljava/lang/String;)Ljava/util/Date;
    :try_end_0
    .catch Ljava/text/ParseException; {:try_start_0 .. :try_end_0} :catch_0

    move-result-object v2

    .line 122
    :goto_0
    iget-object v1, v6, Lcom/opongo/blogapp/common/Post;->categories:Ljava/lang/String;

    .line 124
    .local v1, categories:Ljava/lang/String;
    invoke-virtual {v7}, Landroid/view/View;->getTag()Ljava/lang/Object;

    move-result-object v8

    check-cast v8, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;

    .line 127
    .restart local v8       #viewHolder:Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;
    #getter for: Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->mTitleText:Landroid/widget/TextView;
    invoke-static {v8}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->access$4(Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;)Landroid/widget/TextView;

    move-result-object v9

    iget-object v10, v6, Lcom/opongo/blogapp/common/Post;->title:Ljava/lang/String;

    invoke-virtual {v9, v10}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 129
    #getter for: Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->mDetailText:Landroid/widget/TextView;
    invoke-static {v8}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->access$5(Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;)Landroid/widget/TextView;

    move-result-object v9

    new-instance v10, Ljava/lang/StringBuilder;

    iget-object v11, p0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->pTime:Lcom/ocpsoft/pretty/time/PrettyTime;

    invoke-virtual {v11, v2}, Lcom/ocpsoft/pretty/time/PrettyTime;->format(Ljava/util/Date;)Ljava/lang/String;

    move-result-object v11

    invoke-static {v11}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v11

    invoke-direct {v10, v11}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v11, " in "

    invoke-virtual {v10, v11}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v10

    const/16 v11, 0x46

    invoke-static {v10, v11}, Lcom/opongo/blogapp/utils/StringUtils;->crop(Ljava/lang/String;I)Ljava/lang/String;

    move-result-object v10

    invoke-virtual {v9, v10}, Landroid/widget/TextView;->setText(Ljava/lang/CharSequence;)V

    .line 131
    #getter for: Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->mCommentsCount:Landroid/widget/Button;
    invoke-static {v8}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->access$6(Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;)Landroid/widget/Button;

    move-result-object v9

    iget v10, v6, Lcom/opongo/blogapp/common/Post;->commentsCount:I

    invoke-static {v10}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v10

    invoke-virtual {v9, v10}, Landroid/widget/Button;->setText(Ljava/lang/CharSequence;)V

    .line 134
    #getter for: Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->mCommentsCount:Landroid/widget/Button;
    invoke-static {v8}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->access$6(Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;)Landroid/widget/Button;

    move-result-object v9

    iget v10, v6, Lcom/opongo/blogapp/common/Post;->id:I

    invoke-static {v10}, Ljava/lang/String;->valueOf(I)Ljava/lang/String;

    move-result-object v10

    invoke-virtual {v9, v10}, Landroid/widget/Button;->setTag(Ljava/lang/Object;)V

    .line 135
    #getter for: Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->mCommentsCount:Landroid/widget/Button;
    invoke-static {v8}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->access$6(Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;)Landroid/widget/Button;

    move-result-object v9

    new-instance v10, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$1;

    invoke-direct {v10, p0}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$1;-><init>(Lcom/opongo/blogapp/adapter/PostCacheListAdapter;)V

    invoke-virtual {v9, v10}, Landroid/widget/Button;->setOnClickListener(Landroid/view/View$OnClickListener;)V

    .line 148
    iget-object v4, v6, Lcom/opongo/blogapp/common/Post;->imageUrl:Ljava/lang/String;

    .line 149
    .local v4, imgUrl:Ljava/lang/String;
    #getter for: Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->mThumbImg:Landroid/widget/ImageView;
    invoke-static {v8}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->access$7(Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;)Landroid/widget/ImageView;

    move-result-object v9

    if-eqz v9, :cond_5

    .line 150
    invoke-virtual {v4}, Ljava/lang/String;->length()I

    move-result v9

    const/16 v10, 0xa

    if-le v9, v10, :cond_3

    .line 151
    #getter for: Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->mThumbImg:Landroid/widget/ImageView;
    invoke-static {v8}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->access$7(Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;)Landroid/widget/ImageView;

    move-result-object v9

    const v10, 0x7f020018

    invoke-virtual {v9, v10}, Landroid/widget/ImageView;->setImageResource(I)V

    .line 152
    iget-object v9, p0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->imageManager:Lcom/opongo/blogapp/manager/ImageManager;

    iget-object v10, p0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->activity:Landroid/app/Activity;

    #getter for: Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->mThumbImg:Landroid/widget/ImageView;
    invoke-static {v8}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->access$7(Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;)Landroid/widget/ImageView;

    move-result-object v11

    invoke-virtual {v9, v4, v10, v11}, Lcom/opongo/blogapp/manager/ImageManager;->displayImage(Ljava/lang/String;Landroid/app/Activity;Landroid/widget/ImageView;)V

    .line 161
    :cond_1
    :goto_1
    iget v5, v6, Lcom/opongo/blogapp/common/Post;->opened:I

    .line 163
    .local v5, isOpened:I
    const/4 v9, 0x1

    if-ne v5, v9, :cond_6

    .line 164
    #getter for: Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->mTitleText:Landroid/widget/TextView;
    invoke-static {v8}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->access$4(Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;)Landroid/widget/TextView;

    move-result-object v9

    const/16 v10, 0x40

    const/4 v11, 0x0

    const/4 v12, 0x0

    const/4 v13, 0x0

    invoke-static {v10, v11, v12, v13}, Landroid/graphics/Color;->argb(IIII)I

    move-result v10

    invoke-virtual {v9, v10}, Landroid/widget/TextView;->setTextColor(I)V

    .line 170
    .end local v1           #categories:Ljava/lang/String;
    .end local v2           #date:Ljava/util/Date;
    .end local v4           #imgUrl:Ljava/lang/String;
    .end local v5           #isOpened:I
    .end local v8           #viewHolder:Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;
    :cond_2
    :goto_2
    return-object v7

    .line 117
    .restart local v2       #date:Ljava/util/Date;
    :catch_0
    move-exception v3

    .line 118
    .local v3, e:Ljava/text/ParseException;
    invoke-virtual {v3}, Ljava/text/ParseException;->printStackTrace()V

    goto/16 :goto_0

    .line 154
    .end local v3           #e:Ljava/text/ParseException;
    .restart local v1       #categories:Ljava/lang/String;
    .restart local v4       #imgUrl:Ljava/lang/String;
    .restart local v8       #viewHolder:Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;
    :cond_3
    sget-boolean v9, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->DEBUG:Z

    if-eqz v9, :cond_4

    sget-object v9, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->TAG:Ljava/lang/String;

    new-instance v10, Ljava/lang/StringBuilder;

    const-string v11, "Image url to short to be valid: "

    invoke-direct {v10, v11}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-virtual {v10, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v10

    invoke-virtual {v10}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v10

    invoke-static {v9, v10}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 155
    :cond_4
    #getter for: Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->mThumbImg:Landroid/widget/ImageView;
    invoke-static {v8}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->access$7(Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;)Landroid/widget/ImageView;

    move-result-object v9

    const v10, 0x7f020018

    invoke-virtual {v9, v10}, Landroid/widget/ImageView;->setImageResource(I)V

    goto :goto_1

    .line 158
    :cond_5
    sget-boolean v9, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->DEBUG:Z

    if-eqz v9, :cond_1

    sget-object v9, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->TAG:Ljava/lang/String;

    const-string v10, "Thumbnail holder is null!"

    invoke-static {v9, v10}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    goto :goto_1

    .line 166
    .restart local v5       #isOpened:I
    :cond_6
    #getter for: Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->mTitleText:Landroid/widget/TextView;
    invoke-static {v8}, Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;->access$4(Lcom/opongo/blogapp/adapter/PostCacheListAdapter$ViewHolder;)Landroid/widget/TextView;

    move-result-object v9

    const/16 v10, 0xff

    const/4 v11, 0x0

    const/4 v12, 0x0

    const/4 v13, 0x0

    invoke-static {v10, v11, v12, v13}, Landroid/graphics/Color;->argb(IIII)I

    move-result v10

    invoke-virtual {v9, v10}, Landroid/widget/TextView;->setTextColor(I)V

    goto :goto_2
.end method

.method public stopImgLoaderThread()V
    .locals 1

    .prologue
    .line 174
    iget-object v0, p0, Lcom/opongo/blogapp/adapter/PostCacheListAdapter;->imageManager:Lcom/opongo/blogapp/manager/ImageManager;

    invoke-virtual {v0}, Lcom/opongo/blogapp/manager/ImageManager;->stopThread()V

    .line 175
    return-void
.end method
